package com.corhyfar.dao.impl;

import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.ArrayList;
import java.util.List;

import com.corhyfar.beans.TipoPlanControlDTO;
import com.corhyfar.dao.TipoPlanControlDAO;
import com.corhyfar.util.SQLConnection;

public class TipoPCDaoImpl implements TipoPlanControlDAO {

	Connection cn = null;
	PreparedStatement ps = null;
	ResultSet rs = null;

	@Override
	public List<TipoPlanControlDTO> listarTipoPlanControl() throws SQLException {
		cn = new SQLConnection().GetConnection();
		String sql = "select * from Actividad";
		ps = cn.prepareStatement(sql);
		rs = ps.executeQuery();
		List<TipoPlanControlDTO> lista = new ArrayList<TipoPlanControlDTO>();
		while (rs.next()) {

			lista.add(new TipoPlanControlDTO(rs.getInt(0), rs.getString(1), rs
					.getInt(2)));

		}

		ps.close();
		cn.close();
		return lista;

	}

}
